home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume15 / dis88 / part02 < prev    next >
Encoding:
Internet Message Format  |  1988-05-23  |  58.0 KB

  1. Subject:  v15i007:  Symbolic disassembler for PC/IX, Part02/02
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4.  
  5. Submitted-by: "G. M. Harding" <gm@uts.amdahl.com>
  6. Posting-number: Volume 15, Issue 7
  7. Archive-name: dis88/part02
  8.  
  9. #! /bin/sh
  10. # This is a shell archive.  Remove anything before this line, then unpack
  11. # it by saving it into a file and typing "sh file".  To overwrite existing
  12. # files, type "sh file -c".  You can also feed this as standard input via
  13. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  14. # will see the following message at the end:
  15. #        "End of archive 2 (of 2)."
  16. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  17. if test -f 'dishand.c' -a "${1}" != "-c" ; then 
  18.   echo shar: Will not clobber existing file \"'dishand.c'\"
  19. else
  20. echo shar: Extracting \"'dishand.c'\" \(25688 characters\)
  21. sed "s/^X//" >'dishand.c' <<'END_OF_FILE'
  22. static char *sccsid =
  23. X   "@(#) dishand.c, Ver. 2.1 created 00:00:00 87/09/01";
  24. X
  25. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  26. X  *                                                         *
  27. X  *  Copyright (C) 1987 G. M. Harding, all rights reserved  *
  28. X  *                                                         *
  29. X  * Permission to copy and  redistribute is hereby granted, *
  30. X  * provided full source code,  with all copyright notices, *
  31. X  * accompanies any redistribution.                         *
  32. X  *                                                         *
  33. X  * This file contains the source code for most of the spe- *
  34. X  * cialized handler routines of the disassembler  program. *
  35. X  * (The file disfp.c contains handler routines specific to *
  36. X  * the 8087 numeric  co-processor.)  Each handler  routine *
  37. X  * interprets the opcode byte  (and subsequent data bytes, *
  38. X  * if any)  of a particular family of opcodes,  and is re- *
  39. X  * sponsible for generating appropriate output. All of the *
  40. X  * code in this file is highly MACHINE-SPECIFIC, and would *
  41. X  * have to be rewritten for a different  CPU.  The handler *
  42. X  * routines are accessed  only via pointers in the optab[] *
  43. X  * array, however, so machine dependencies are confined to *
  44. X  * this file, its sister file "disfp.c", and the data file *
  45. X  * "distabs.c".                                            *
  46. X  *                                                         *
  47. X  * All of the code in this file is based on the assumption *
  48. X  * of sixteen-bit integers.                                *
  49. X  *                                                         *
  50. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  51. X
  52. X#include "dis.h"              /* Disassembler declarations  */
  53. X
  54. int segflg;                   /* Segment-override flag      */
  55. X
  56. unsigned char objbuf[OBJMAX]; /* Buffer for object code     */
  57. X
  58. int objptr;                   /* Index into objbuf[]        */
  59. X
  60. unsigned long PC;             /* Current program counter    */
  61. X
  62. X /* * * * * *  MISCELLANEOUS SUPPORTING ROUTINES  * * * * * */
  63. X
  64. X
  65. void
  66. objini(j)                     /* Object code init routine   */
  67. X
  68. X   register int j;
  69. X
  70. X{
  71. X   if ((segflg == 1) || (segflg == 2))
  72. X      segflg *= 3;
  73. X   else
  74. X      segflg = 0;
  75. X   objptr = 0;
  76. X   objbuf[objptr++] = (unsigned char)(j);
  77. X}
  78. X
  79. X
  80. void
  81. objout()                      /* Object-code output routine */
  82. X
  83. X{
  84. X    register int k;
  85. X
  86. X   if ( ! objflg )
  87. X      return;
  88. X   else
  89. X      {
  90. X      printf("\t|");
  91. X      if (symptr >= 0)
  92. X         printf(" %05.5lx:",(PC + 1L - (long)(objptr)));
  93. X      for (k = 0; k < objptr; ++k)
  94. X         printf(" %02.2x",objbuf[k]);
  95. X      putchar('\n');
  96. X      }
  97. X}
  98. X
  99. X
  100. void
  101. badseq(j,k)                   /* Invalid-sequence routine   */
  102. X
  103. X   register int j, k;
  104. X
  105. X{
  106. X   printf("\t.byte\t0x%02.2x\t\t| invalid code sequence\n",j);
  107. X   printf("\t.byte\t0x%02.2x\n",k);
  108. X}
  109. X
  110. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  111. X  *                                                         *
  112. X  * This  routine  is the first of several  opcode-specific *
  113. X  * handlers,  each of which is  dedicated  to a particular *
  114. X  * opcode family.  A pointer to a handler  routine is con- *
  115. X  * tained in the second field of each optab[]  entry.  The *
  116. X  * dfhand()  routine is the default handler,  invoked when *
  117. X  * no other handler is appropriate (generally, when an in- *
  118. X  * valid opcode is encountered).                           *
  119. X  *                                                         *
  120. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  121. X
  122. void
  123. dfhand(j)
  124. X
  125. X   register int j;            /* Pointer to optab[] entry   */
  126. X
  127. X{/* * * * * * * * * *  START OF dfhand()  * * * * * * * * * */
  128. X
  129. X   segflg = 0;
  130. X
  131. X   printf("\t.byte\t0x%02.2x",j);
  132. X
  133. X   if (optab[j].min || optab[j].max)
  134. X      putchar('\n');
  135. X   else
  136. X      printf("\t\t| unimplemented opcode\n");
  137. X
  138. X}/* * * * * * * * * * * END OF dfhand() * * * * * * * * * * */
  139. X
  140. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  141. X  *                                                         *
  142. X  * This is the  single-byte  handler,  invoked  whenever a *
  143. X  * one-byte opcode is encountered.                         *
  144. X  *                                                         *
  145. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  146. X
  147. void
  148. sbhand(j)
  149. X
  150. X   register int j;            /* Pointer to optab[] entry   */
  151. X
  152. X{/* * * * * * * * * *  START OF sbhand()  * * * * * * * * * */
  153. X
  154. X   objini(j);
  155. X
  156. X   if (j == 0x2e)                               /* seg cs   */
  157. X      segflg = 1;
  158. X
  159. X   if ((j == 0x26)                              /* seg es   */
  160. X    || (j == 0x36)                              /* seg ss   */
  161. X    || (j == 0x3e))                             /* seg ds   */
  162. X      segflg = 2;
  163. X
  164. X   printf("%s\n",optab[j].text);
  165. X
  166. X   objout();
  167. X
  168. X}/* * * * * * * * * * * END OF sbhand() * * * * * * * * * * */
  169. X
  170. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  171. X  *                                                         *
  172. X  * This is the handler for most of the processor's regular *
  173. X  * arithmetic operations.                                  *
  174. X  *                                                         *
  175. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  176. X
  177. void
  178. aohand(j)
  179. X
  180. X   register int j;            /* Pointer to optab[] entry   */
  181. X
  182. X{/* * * * * * * * * *  START OF aohand()  * * * * * * * * * */
  183. X
  184. X   register int k;
  185. X   int m, n;
  186. X   char b[64];
  187. X
  188. X   objini(j);
  189. X
  190. X   switch (j & 7)
  191. X      {
  192. X      case 0 :
  193. X      case 1 :
  194. X      case 2 :
  195. X      case 3 :
  196. X         printf("%s\t",optab[j].text);
  197. X         FETCH(k);
  198. X         printf("%s\n",mtrans(j,k,TR_STD));
  199. X         break;
  200. X      case 4 :
  201. X         FETCH(k);
  202. X         printf("%s\tal,*0x%02.2x\n",optab[j].text,k);
  203. X         break;
  204. X      case 5 :
  205. X         FETCH(m);
  206. X         FETCH(n);
  207. X         k = (n << 8) | m;
  208. X         if (lookext((long)(k),(PC - 1),b))
  209. X            printf("%s\tax,#%s\n",optab[j].text,b);
  210. X         else
  211. X            printf("%s\tax,#0x%04.4x\n",optab[j].text,k);
  212. X         break;
  213. X      default :
  214. X         dfhand(j);
  215. X         break;
  216. X      }
  217. X
  218. X   objout();
  219. X
  220. X}/* * * * * * * * * * * END OF aohand() * * * * * * * * * * */
  221. X
  222. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  223. X  *                                                         *
  224. X  * This is the  handler for opcodes  which  perform  short *
  225. X  * (eight-bit) relative jumps.                             *
  226. X  *                                                         *
  227. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  228. X
  229. void
  230. sjhand(j)
  231. X
  232. X   register int j;            /* Pointer to optab[] entry   */
  233. X
  234. X{/* * * * * * * * * *  START OF sjhand()  * * * * * * * * * */
  235. X
  236. X   register int k;
  237. X   int m;
  238. X
  239. X   objini(j);
  240. X
  241. X   FETCH(m);
  242. X
  243. X   if (m & 0x80)
  244. X      k = 0xff00;
  245. X   else
  246. X      k = 0;
  247. X
  248. X   k |= m;
  249. X
  250. X   printf("%s\t%s\t\t| loc %05.5lx\n",optab[j].text,
  251. X    lookup((PC + k + 1L),N_TEXT,LOOK_REL,-1L),
  252. X    (PC + k + 1L));
  253. X
  254. X   objout();
  255. X
  256. X}/* * * * * * * * * * * END OF sjhand() * * * * * * * * * * */
  257. X
  258. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  259. X  *                                                         *
  260. X  * This is the  handler for a  loosely-knit  family of op- *
  261. X  * codes which perform  arithmetic and logical operations, *
  262. X  * and which take immediate  data.  The routine's logic is *
  263. X  * rather complex,  so,  in an effort to avoid  additional *
  264. X  * complexity,  the search for external  references in the *
  265. X  * relocation table has been dispensed with. Eager hackers *
  266. X  * can try their hand at coding such a search.             *
  267. X  *                                                         *
  268. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  269. X
  270. void
  271. imhand(j)
  272. X
  273. X   register int j;            /* Pointer to optab[] entry   */
  274. X
  275. X{/* * * * * * * * * *  START OF imhand()  * * * * * * * * * */
  276. X
  277. X   unsigned long pc;
  278. X   register int k;
  279. X   int offset, oflag, immed, iflag, mod, opi, w, rm;
  280. X   int m, n;
  281. X   static char a[100], b[30];
  282. X
  283. X   objini(j);
  284. X
  285. X   FETCH(k);
  286. X
  287. X   pc = PC + 1;
  288. X
  289. X   offset = 0;
  290. X   mod = (k & 0xc0) >> 6;
  291. X   opi = (k & 0x38) >> 3;
  292. X   w = j & 1;
  293. X   rm = k & 7;
  294. X
  295. X   if ((j & 2)
  296. X    && ((opi == 1)
  297. X     || (opi == 4)
  298. X     || (opi == 6)))
  299. X      {
  300. X      badseq(j,k);
  301. X      return;
  302. X      }
  303. X
  304. X   strcpy(a,OPFAM[opi]);
  305. X
  306. X   if ( ! w )
  307. X      strcat(a,"b");
  308. X
  309. X   if ((oflag = mod) > 2)
  310. X      oflag = 0;
  311. X
  312. X   if ((mod == 0) && (rm == 6))
  313. X      {
  314. X      FETCH(m);
  315. X      FETCH(n);
  316. X      offset = (n << 8) | m;
  317. X      }
  318. X   else if (oflag)
  319. X      if (oflag == 2)
  320. X         {
  321. X         FETCH(m);
  322. X         FETCH(n);
  323. X         offset = (n << 8) | m;
  324. X         }
  325. X      else
  326. X         {
  327. X         FETCH(m);
  328. X         if (m & 0x80)
  329. X            n = 0xff00;
  330. X         else
  331. X            n = 0;
  332. X         offset = n | m;
  333. X         }
  334. X
  335. X   switch (j & 3)
  336. X      {
  337. X      case 0 :
  338. X      case 2 :
  339. X         FETCH(immed);
  340. X         iflag = 0;
  341. X         break;
  342. X      case 1 :
  343. X         FETCH(m);
  344. X         FETCH(n);
  345. X         immed = (n << 8) | m;
  346. X         iflag = 1;
  347. X         break;
  348. X      case 3 :
  349. X         FETCH(immed);
  350. X         if (immed & 0x80)
  351. X            immed &= 0xff00;
  352. X         iflag = 0;
  353. X         break;
  354. X      }
  355. X
  356. X   strcat(a,"\t");
  357. X
  358. X   switch (mod)
  359. X      {
  360. X      case 0 :
  361. X         if (rm == 6)
  362. X            strcat(a,
  363. X             lookup((long)(offset),N_DATA,LOOK_ABS,pc));
  364. X         else
  365. X            {
  366. X            sprintf(b,"(%s)",REGS0[rm]);
  367. X            strcat(a,b);
  368. X            }
  369. X         break;
  370. X      case 1 :
  371. X      case 2 :
  372. X         if (mod == 1)
  373. X            strcat(a,"*");
  374. X         else
  375. X            strcat(a,"#");
  376. X         sprintf(b,"%d(",offset);
  377. X         strcat(a,b);
  378. X         strcat(a,REGS1[rm]);
  379. X         strcat(a,")");
  380. X         break;
  381. X      case 3 :
  382. X         strcat(a,REGS[(w << 3) | rm]);
  383. X         break;
  384. X      }
  385. X
  386. X   strcat(a,",");
  387. X   if (iflag)
  388. X      strcat(a,"#");
  389. X   else
  390. X      strcat(a,"*");
  391. X   sprintf(b,"%d",immed);
  392. X   strcat(a,b);
  393. X
  394. X   printf("%s\n",a);
  395. X
  396. X   objout();
  397. X
  398. X}/* * * * * * * * * * * END OF imhand() * * * * * * * * * * */
  399. X
  400. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  401. X  *                                                         *
  402. X  * This is the  handler  for  various  "mov"-type  opcodes *
  403. X  * which use the mod,  reg,  and r/m  fields of the second *
  404. X  * code byte in a standard, straightforward way.           *
  405. X  *                                                         *
  406. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  407. X
  408. void
  409. mvhand(j)
  410. X
  411. X   int j;                     /* Pointer to optab[] entry   */
  412. X
  413. X{/* * * * * * * * * *  START OF mvhand()  * * * * * * * * * */
  414. X
  415. X   register int k, m = j;
  416. X
  417. X   objini(j);
  418. X
  419. X   FETCH(k);
  420. X
  421. X   if ((m == 0x84) || (m == 0x85)      /* Kind of kludgey   */
  422. X    || (m == 0xc4) || (m == 0xc5)
  423. X    || (m == 0x8d))
  424. X      if (m & 0x40)
  425. X         m |= 0x03;
  426. X      else
  427. X         m |= 0x02;
  428. X
  429. X   printf("%s\t%s\n",optab[j].text,mtrans(m,k,TR_STD));
  430. X
  431. X   objout();
  432. X
  433. X}/* * * * * * * * * * * END OF mvhand() * * * * * * * * * * */
  434. X
  435. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  436. X  *                                                         *
  437. X  * This is the handler for segment-register "mov" opcodes. *
  438. X  *                                                         *
  439. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  440. X
  441. void
  442. mshand(j)
  443. X
  444. X   register int j;            /* Pointer to optab[] entry   */
  445. X
  446. X{/* * * * * * * * * *  START OF mshand()  * * * * * * * * * */
  447. X
  448. X   register int k;
  449. X
  450. X   objini(j);
  451. X
  452. X   FETCH(k);
  453. X
  454. X   if (k & 0x20)
  455. X      {
  456. X      badseq(j,k);
  457. X      return;
  458. X      }
  459. X
  460. X   printf("%s\t%s\n",optab[j].text,mtrans(j,k,TR_SEG));
  461. X
  462. X   objout();
  463. X
  464. X}/* * * * * * * * * * * END OF mshand() * * * * * * * * * * */
  465. X
  466. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  467. X  *                                                         *
  468. X  * This is the  handler for pops,  other than  single-byte *
  469. X  * pops.  (The 8088 allows  popping into any register,  or *
  470. X  * directly into memory,  accessed  either  immediately or *
  471. X  * through a register and an index.)                       *
  472. X  *                                                         *
  473. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  474. X
  475. void
  476. pohand(j)
  477. X
  478. X   register int j;            /* Pointer to optab[] entry   */
  479. X
  480. X{/* * * * * * * * * *  START OF pohand()  * * * * * * * * * */
  481. X
  482. X   char *a;
  483. X   register int k;
  484. X
  485. X   objini(j);
  486. X
  487. X   FETCH(k);
  488. X
  489. X   if (k & 0x38)
  490. X      {
  491. X      badseq(j,k);
  492. X      return;
  493. X      }
  494. X
  495. X   printf("%s\t",optab[j].text);
  496. X
  497. X   a = mtrans((j & 0xfd),k,TR_STD);
  498. X
  499. X   mtrunc(a);
  500. X
  501. X   printf("%s\n",a);
  502. X
  503. X   objout();
  504. X
  505. X}/* * * * * * * * * * * END OF pohand() * * * * * * * * * * */
  506. X
  507. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  508. X  *                                                         *
  509. X  * This is the handler routine for intersegment  calls and *
  510. X  * jumps.  Its output is never symbolic,  because the host *
  511. X  * linker  does not allow  symbolic  intersegment  address *
  512. X  * references except by means of symbolic  constants,  and *
  513. X  * any such  constants in the symbol  table,  even if they *
  514. X  * are of the  appropriate  value,  may be misleading.  In *
  515. X  * compiled code,  intersegment  references  should not be *
  516. X  * encountered,  and even in assembled  code,  they should *
  517. X  * occur infrequently. If and when they do occur, however, *
  518. X  * they will be disassembled in absolute form.             *
  519. X  *                                                         *
  520. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  521. X
  522. void
  523. cihand(j)
  524. X
  525. X   int j;                     /* Pointer to optab[] entry   */
  526. X
  527. X{/* * * * * * * * * *  START OF cihand()  * * * * * * * * * */
  528. X
  529. X   register int m, n;
  530. X
  531. X   objini(j);
  532. X
  533. X   printf("%s\t",optab[j].text);
  534. X
  535. X   FETCH(m);
  536. X   FETCH(n);
  537. X
  538. X   printf("#0x%04.4x,",((n << 8) | m));
  539. X
  540. X   FETCH(m);
  541. X   FETCH(n);
  542. X
  543. X   printf("#0x%04.4x\n",((n << 8) | m));
  544. X
  545. X   objout();
  546. X
  547. X}/* * * * * * * * * * * END OF cihand() * * * * * * * * * * */
  548. X
  549. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  550. X  *                                                         *
  551. X  * This is the handler for  "mov"  opcodes with  immediate *
  552. X  * data.                                                   *
  553. X  *                                                         *
  554. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  555. X
  556. void
  557. mihand(j)
  558. X
  559. X   register int j;            /* Pointer to optab[] entry   */
  560. X
  561. X{/* * * * * * * * * *  START OF mihand()  * * * * * * * * * */
  562. X
  563. X   register int k;
  564. X   int m, n;
  565. X   char b[64];
  566. X
  567. X   objini(j);
  568. X
  569. X   printf("%s",optab[j].text);
  570. X
  571. X   if (j & 8)
  572. X      {
  573. X      FETCH(m);
  574. X      FETCH(n);
  575. X      k = ((n << 8) | m);
  576. X      if (lookext((long)(k),(PC - 1),b))
  577. X         printf("#%s\n",b);
  578. X      else
  579. X         printf("#%d\n",k);
  580. X      }
  581. X   else
  582. X      {
  583. X      FETCH(m);
  584. X      printf("*%d\n",m);
  585. X      }
  586. X
  587. X   objout();
  588. X
  589. X}/* * * * * * * * * * * END OF mihand() * * * * * * * * * * */
  590. X
  591. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  592. X  *                                                         *
  593. X  * This is the handler for a family of quick-move opcodes. *
  594. X  *                                                         *
  595. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  596. X
  597. void
  598. mqhand(j)
  599. X
  600. X   int j;                     /* Pointer to optab[] entry   */
  601. X
  602. X{/* * * * * * * * * *  START OF mqhand()  * * * * * * * * * */
  603. X
  604. X   unsigned long pc;
  605. X   register int m, n;
  606. X
  607. X   objini(j);
  608. X
  609. X   pc = PC + 1;
  610. X
  611. X   FETCH(m);
  612. X   FETCH(n);
  613. X
  614. X   m = (n << 8) | m;
  615. X
  616. X   printf("%s\t",optab[j].text);
  617. X
  618. X   if (j & 2)
  619. X      printf("%s,%s\n",
  620. X       lookup((long)(m),N_DATA,LOOK_ABS,pc),
  621. X       REGS[(j & 1) << 3]);
  622. X   else
  623. X      printf("%s,%s\n",
  624. X       REGS[(j & 1) << 3],
  625. X       lookup((long)(m),N_DATA,LOOK_ABS,pc));
  626. X
  627. X   objout();
  628. X
  629. X}/* * * * * * * * * * * END OF mqhand() * * * * * * * * * * */
  630. X
  631. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  632. X  *                                                         *
  633. X  * This is the handler for a family of quick-test opcodes. *
  634. X  *                                                         *
  635. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  636. X
  637. void
  638. tqhand(j)
  639. X
  640. X   int j;                     /* Pointer to optab[] entry   */
  641. X
  642. X{/* * * * * * * * * *  START OF tqhand()  * * * * * * * * * */
  643. X
  644. X   register int m, n;
  645. X   int k;
  646. X   char b[64];
  647. X
  648. X   objini(j);
  649. X
  650. X   printf("%s\t%s,",optab[j].text,REGS[(j & 1) << 3]);
  651. X
  652. X   FETCH(m);
  653. X
  654. X   if (j & 1)
  655. X      {
  656. X      FETCH(n);
  657. X      k = ((n << 8) | m);
  658. X      if (lookext((long)(k),(PC - 1),b))
  659. X         printf("#%s\n",b);
  660. X      else
  661. X         printf("#%d\n",k);
  662. X      }
  663. X   else
  664. X      {
  665. X      if (m & 80)
  666. X         m |= 0xff00;
  667. X      printf("*%d\n",m);
  668. X      }
  669. X
  670. X   objout();
  671. X
  672. X}/* * * * * * * * * * * END OF tqhand() * * * * * * * * * * */
  673. X
  674. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  675. X  *                                                         *
  676. X  * This is the handler for multiple-byte "return" opcodes. *
  677. X  * The 8088 allows returns to take an optional  16-bit ar- *
  678. X  * gument,  which  reflects  the  amount to be added to SP *
  679. X  * after  the pop of the  return  address.  The idea is to *
  680. X  * facilitate  the use of local  parameters  on the stack. *
  681. X  * After some  rumination,  it was decided to  disassemble *
  682. X  * any such arguments as absolute quantities,  rather than *
  683. X  * rummaging  through the symbol table for possible corre- *
  684. X  * sponding constants.                                     *
  685. X  *                                                         *
  686. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  687. X
  688. void
  689. rehand(j)
  690. X
  691. X   int j;                     /* Pointer to optab[] entry   */
  692. X
  693. X{/* * * * * * * * * *  START OF rehand()  * * * * * * * * * */
  694. X
  695. X   register int m, n;
  696. X
  697. X   objini(j);
  698. X
  699. X   FETCH(m);
  700. X   FETCH(n);
  701. X
  702. X   m = (n << 8) | m;
  703. X
  704. X   printf("%s\t#0x%04.4x\n",optab[j].text,m);
  705. X
  706. X   objout();
  707. X
  708. X}/* * * * * * * * * * * END OF rehand() * * * * * * * * * * */
  709. X
  710. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  711. X  *                                                         *
  712. X  * This is the handler for "mov"  opcodes involving memory *
  713. X  * and immediate data.                                     *
  714. X  *                                                         *
  715. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  716. X
  717. void
  718. mmhand(j)
  719. X
  720. X   register int j;            /* Pointer to optab[] entry   */
  721. X
  722. X{/* * * * * * * * * *  START OF mmhand()  * * * * * * * * * */
  723. X
  724. X   char *a;
  725. X   register int k;
  726. X   char b[64];
  727. X
  728. X   objini(j);
  729. X
  730. X   FETCH(k);
  731. X
  732. X   if (k & 0x38)
  733. X      {
  734. X      badseq(j,k);
  735. X      return;
  736. X      }
  737. X
  738. X   printf("%s",optab[j].text);
  739. X
  740. X   if ( ! (j & 1) )
  741. X      putchar('b');
  742. X
  743. X   a = mtrans((j & 0xfd),(k & 0xc7),TR_STD);
  744. X
  745. X   mtrunc(a);
  746. X
  747. X   printf("\t%s,",a);
  748. X
  749. X   if (j & 1)
  750. X      {
  751. X      FETCH(j);
  752. X      FETCH(k);
  753. X      k = (k << 8) | j;
  754. X      if (lookext((long)(k),(PC - 1),b))
  755. X         printf("#%s\n",b);
  756. X      else
  757. X         printf("#%d\n",k);
  758. X      }
  759. X   else
  760. X      {
  761. X      FETCH(k);
  762. X      printf("*%d\n",k);
  763. X      }
  764. X
  765. X   objout();
  766. X
  767. X}/* * * * * * * * * * * END OF mmhand() * * * * * * * * * * */
  768. X
  769. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  770. X  *                                                         *
  771. X  * This is the  handler  for the 8088  family of shift and *
  772. X  * rotate instructions.                                    *
  773. X  *                                                         *
  774. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  775. X
  776. void
  777. srhand(j)
  778. X
  779. X   register int j;            /* Pointer to optab[] entry   */
  780. X
  781. X{/* * * * * * * * * *  START OF srhand()  * * * * * * * * * */
  782. X
  783. X   char *a;
  784. X   register int k;
  785. X
  786. X   objini(j);
  787. X
  788. X   FETCH(k);
  789. X
  790. X   if ((k & 0x38) == 0x30)
  791. X      {
  792. X      badseq(j,k);
  793. X      return;
  794. X      }
  795. X
  796. X   printf("%s",OPFAM[((k & 0x38) >> 3) + 16]);
  797. X
  798. X   if ( ! (j & 1) )
  799. X      putchar('b');
  800. X
  801. X   a = mtrans((j & 0xfd),(k & 0xc7),TR_STD);
  802. X
  803. X   mtrunc(a);
  804. X
  805. X   printf("\t%s",a);
  806. X
  807. X   if (j & 2)
  808. X      printf(",cl\n");
  809. X   else
  810. X      printf(",*1\n");
  811. X
  812. X   objout();
  813. X
  814. X}/* * * * * * * * * * * END OF srhand() * * * * * * * * * * */
  815. X
  816. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  817. X  *                                                         *
  818. X  * This is the handler for the ASCII-adjust opcodes.       *
  819. X  *                                                         *
  820. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  821. X
  822. void
  823. aahand(j)
  824. X
  825. X   register int j;            /* Pointer to optab[] entry   */
  826. X
  827. X{/* * * * * * * * * *  START OF aahand()  * * * * * * * * * */
  828. X
  829. X   register int k;
  830. X
  831. X   objini(j);
  832. X
  833. X   FETCH(k);
  834. X
  835. X   if (k != 0x0a)
  836. X      {
  837. X      badseq(j,k);
  838. X      return;
  839. X      }
  840. X
  841. X   printf("%s\n",optab[j].text);
  842. X
  843. X   objout();
  844. X
  845. X}/* * * * * * * * * * * END OF aahand() * * * * * * * * * * */
  846. X
  847. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  848. X  *                                                         *
  849. X  * This is the handler for port I/O opcodes  which specify *
  850. X  * the port address as an immediate operand.               *
  851. X  *                                                         *
  852. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  853. X
  854. void
  855. iohand(j)
  856. X
  857. X   register int j;            /* Pointer to optab[] entry   */
  858. X
  859. X{/* * * * * * * * * *  START OF iohand()  * * * * * * * * * */
  860. X
  861. X   register int k;
  862. X
  863. X   objini(j);
  864. X
  865. X   FETCH(k);
  866. X
  867. X   printf("%s\t0x%02.2x\n",optab[j].text,k);
  868. X
  869. X   objout();
  870. X
  871. X}/* * * * * * * * * * * END OF iohand() * * * * * * * * * * */
  872. X
  873. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  874. X  *                                                         *
  875. X  * This is the  handler  for opcodes  which  perform  long *
  876. X  * (sixteen-bit) relative jumps and calls.                 *
  877. X  *                                                         *
  878. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  879. X
  880. void
  881. ljhand(j)
  882. X
  883. X   register int j;            /* Pointer to optab[] entry   */
  884. X
  885. X{/* * * * * * * * * *  START OF ljhand()  * * * * * * * * * */
  886. X
  887. X   register int k;
  888. X   int m, n;
  889. X
  890. X   objini(j);
  891. X
  892. X   FETCH(m);
  893. X   FETCH(n);
  894. X
  895. X   k = (n << 8) | m;
  896. X
  897. X   printf("%s\t%s\t\t| loc %05.5lx\n",optab[j].text,
  898. X    lookup((PC + k + 1L),N_TEXT,LOOK_LNG,(PC - 1L)),
  899. X    (PC + k + 1L));
  900. X
  901. X   objout();
  902. X
  903. X}/* * * * * * * * * * * END OF ljhand() * * * * * * * * * * */
  904. X
  905. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  906. X  *                                                         *
  907. X  * This is the handler for a pair of oddball opcodes (0xf6 *
  908. X  * and 0xf7) which perform miscellaneous arithmetic opera- *
  909. X  * tions not dealt with elsewhere.                         *
  910. X  *                                                         *
  911. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  912. X
  913. void
  914. mahand(j)
  915. X
  916. X   register int j;            /* Pointer to optab[] entry   */
  917. X
  918. X{/* * * * * * * * * *  START OF mahand()  * * * * * * * * * */
  919. X
  920. X   char *a;
  921. X   register int k;
  922. X   char b[64];
  923. X
  924. X   objini(j);
  925. X
  926. X   FETCH(k);
  927. X
  928. X   a = mtrans((j & 0xfd),(k & 0xc7),TR_STD);
  929. X
  930. X   mtrunc(a);
  931. X
  932. X   switch (((k = objbuf[1]) & 0x38) >> 3)
  933. X      {
  934. X      case 0 :
  935. X         printf("\ttest");
  936. X         break;
  937. X      case 1 :
  938. X         badseq(j,k);
  939. X         return;
  940. X      case 2 :
  941. X         printf("\tnot");
  942. X         break;
  943. X      case 3 :
  944. X         printf("\tneg");
  945. X         break;
  946. X      case 4 :
  947. X         printf("\tmul");
  948. X         break;
  949. X      case 5 :
  950. X         printf("\timul");
  951. X         break;
  952. X      case 6 :
  953. X         printf("\tdiv");
  954. X         break;
  955. X      case 7 :
  956. X         printf("\tidiv");
  957. X         break;
  958. X      }
  959. X
  960. X   if ( ! (j & 1) )
  961. X      putchar('b');
  962. X
  963. X   printf("\t%s",a);
  964. X
  965. X   if (k & 0x38)
  966. X      putchar('\n');
  967. X   else
  968. X      if (j & 1)
  969. X         {
  970. X         FETCH(j);
  971. X         FETCH(k);
  972. X         k = (k << 8) | j;
  973. X         if (lookext((long)(k),(PC - 1),b))
  974. X            printf(",#%s\n",b);
  975. X         else
  976. X            printf(",#%d\n",k);
  977. X         }
  978. X      else
  979. X         {
  980. X         FETCH(k);
  981. X         printf(",*%d\n",k);
  982. X         }
  983. X
  984. X   objout();
  985. X
  986. X}/* * * * * * * * * * * END OF mahand() * * * * * * * * * * */
  987. X
  988. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  989. X  *                                                         *
  990. X  * This is the handler for miscellaneous jump, call, push, *
  991. X  * and increment/decrement opcodes  (0xfe and 0xff)  which *
  992. X  * are not dealt with elsewhere.                           *
  993. X  *                                                         *
  994. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  995. X
  996. void
  997. mjhand(j)
  998. X
  999. X   register int j;            /* Pointer to optab[] entry   */
  1000. X
  1001. X{/* * * * * * * * * *  START OF mjhand()  * * * * * * * * * */
  1002. X
  1003. X   char *a;
  1004. X   register int k;
  1005. X
  1006. X   objini(j);
  1007. X
  1008. X   FETCH(k);
  1009. X
  1010. X   a = mtrans((j & 0xfd),(k & 0xc7),TR_STD);
  1011. X
  1012. X   mtrunc(a);
  1013. X
  1014. X   switch (((k = objbuf[1]) & 0x38) >> 3)
  1015. X      {
  1016. X      case 0 :
  1017. X         printf("\tinc");
  1018. X         if ( ! (j & 1) )
  1019. X            putchar('b');
  1020. X         putchar('\t');
  1021. X         break;
  1022. X      case 1 :
  1023. X         printf("\tdec");
  1024. X         if ( ! (j & 1) )
  1025. X            putchar('b');
  1026. X         putchar('\t');
  1027. X         break;
  1028. X      case 2 :
  1029. X         if (j & 1)
  1030. X            printf("\tcall\t@");
  1031. X         else
  1032. X            goto BAD;
  1033. X         break;
  1034. X      case 3 :
  1035. X         if (j & 1)
  1036. X            printf("\tcalli\t@");
  1037. X         else
  1038. X            goto BAD;
  1039. X         break;
  1040. X      case 4 :
  1041. X         if (j & 1)
  1042. X            printf("\tjmp\t@");
  1043. X         else
  1044. X            goto BAD;
  1045. X         break;
  1046. X      case 5 :
  1047. X         if (j & 1)
  1048. X            printf("\tjmpi\t@");
  1049. X         else
  1050. X            goto BAD;
  1051. X         break;
  1052. X      case 6 :
  1053. X         if (j & 1)
  1054. X            printf("\tpush\t");
  1055. X         else
  1056. X            goto BAD;
  1057. X         break;
  1058. X      case 7 :
  1059. X BAD :
  1060. X         badseq(j,k);
  1061. X         return;
  1062. X      }
  1063. X
  1064. X   printf("%s\n",a);
  1065. X
  1066. X   objout();
  1067. X
  1068. X}/* * * * * * * * * * * END OF mjhand() * * * * * * * * * * */
  1069. X
  1070. X
  1071. END_OF_FILE
  1072. if test 25688 -ne `wc -c <'dishand.c'`; then
  1073.     echo shar: \"'dishand.c'\" unpacked with wrong size!
  1074. fi
  1075. # end of 'dishand.c'
  1076. fi
  1077. if test -f 'distabs.c' -a "${1}" != "-c" ; then 
  1078.   echo shar: Will not clobber existing file \"'distabs.c'\"
  1079. else
  1080. echo shar: Extracting \"'distabs.c'\" \(30238 characters\)
  1081. sed "s/^X//" >'distabs.c' <<'END_OF_FILE'
  1082. static char *sccsid =
  1083. X   "@(#) distabs.c, Ver. 2.1 created 00:00:00 87/09/01";
  1084. X
  1085. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1086. X  *                                                         *
  1087. X  *  Copyright (C) 1987 G. M. Harding, all rights reserved  *
  1088. X  *                                                         *
  1089. X  * Permission to copy and  redistribute is hereby granted, *
  1090. X  * provided full source code,  with all copyright notices, *
  1091. X  * accompanies any redistribution.                         *
  1092. X  *                                                         *
  1093. X  * This file  contains  the  lookup  tables and other data *
  1094. X  * structures for the Intel 8088 symbolic disassembler. It *
  1095. X  * also contains a few global  routines  which  facilitate *
  1096. X  * access to the tables,  for use primarily by the handler *
  1097. X  * functions.                                              *
  1098. X  *                                                         *
  1099. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1100. X
  1101. X#include "dis.h"              /* Disassembler declarations  */
  1102. X
  1103. struct exec HDR;              /* Used to hold header info   */
  1104. X
  1105. struct nlist symtab[MAXSYM];  /* Array of symbol table info */
  1106. X
  1107. struct reloc relo[MAXSYM];    /* Array of relocation info   */
  1108. X
  1109. int symptr = -1,              /* Index into symtab[]        */
  1110. X    relptr = -1;              /* Index into relo[]          */
  1111. X
  1112. char *REGS[] =                /* Table of register names    */
  1113. X   {
  1114. X   "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
  1115. X   "ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
  1116. X   "es", "cs", "ss", "ds"
  1117. X   };
  1118. X
  1119. char *REGS0[] =               /* Mode 0 register name table */
  1120. X   {
  1121. X   "bx_si", "bx_di", "bp_si", "bp_di", "si", "di", "", "bx"
  1122. X   };
  1123. X
  1124. char *REGS1[] =               /* Mode 1 register name table */
  1125. X   {
  1126. X   "bx_si", "bx_di", "bp_si", "bp_di", "si", "di", "bp", "bx"
  1127. X   };
  1128. X
  1129. int symrank[6][6] =           /* Symbol type/rank matrix    */
  1130. X   {
  1131. X              /* UND  ABS  TXT  DAT  BSS  COM */
  1132. X   /* UND */      5,   4,   1,   2,   3,   0,
  1133. X   /* ABS */      1,   5,   4,   3,   2,   0,
  1134. X   /* TXT */      4,   1,   5,   3,   2,   0,
  1135. X   /* DAT */      3,   1,   2,   5,   4,   0,
  1136. X   /* BSS */      3,   1,   2,   4,   5,   0,
  1137. X   /* COM */      2,   0,   1,   3,   4,   5
  1138. X   };
  1139. X
  1140. X /* * * * * * * * * * * * OPCODE DATA * * * * * * * * * * * */
  1141. X
  1142. char ADD[]   = "\tadd",             /* Mnemonics by family  */
  1143. X     OR[]    = "\tor",
  1144. X     ADC[]   = "\tadc",
  1145. X     SBB[]   = "\tsbb",
  1146. X     AND[]   = "\tand",
  1147. X     SUB[]   = "\tsub",
  1148. X     XOR[]   = "\txor",
  1149. X     CMP[]   = "\tcmp",
  1150. X     NOT[]   = "\tnot",
  1151. X     NEG[]   = "\tneg",
  1152. X     MUL[]   = "\tmul",
  1153. X     DIV[]   = "\tdiv",
  1154. X     MOV[]   = "\tmov",
  1155. X     ESC[]   = "\tesc",
  1156. X     TEST[]  = "\ttest",
  1157. X     AMBIG[] = "",
  1158. X     ROL[]   = "\trol",
  1159. X     ROR[]   = "\tror",
  1160. X     RCL[]   = "\trcl",
  1161. X     RCR[]   = "\trcr",
  1162. X     SAL[]   = "\tsal",
  1163. X     SHR[]   = "\tshr",
  1164. X     SHL[]   = "\tshl",
  1165. X     SAR[]   = "\tsar";
  1166. X
  1167. char *OPFAM[] =                     /* Family lookup table  */
  1168. X   {
  1169. X   ADD, OR, ADC, SBB, AND, SUB, XOR, CMP,
  1170. X   NOT, NEG, MUL, DIV, MOV, ESC, TEST, AMBIG,
  1171. X   ROL, ROR, RCL, RCR, SAL, SHR, SHL, SAR
  1172. X   };
  1173. X
  1174. struct opcode optab[] =             /* Table of opcode data */
  1175. X   {
  1176. X   ADD,              aohand,  2,    4,             /* 0x00  */
  1177. X   ADD,              aohand,  2,    4,             /* 0x01  */
  1178. X   ADD,              aohand,  2,    4,             /* 0x02  */
  1179. X   ADD,              aohand,  2,    4,             /* 0x03  */
  1180. X   ADD,              aohand,  2,    2,             /* 0x04  */
  1181. X   ADD,              aohand,  3,    3,             /* 0x05  */
  1182. X   "\tpush\tes",     sbhand,  1,    1,             /* 0x06  */
  1183. X   "\tpop\tes",      sbhand,  1,    1,             /* 0x07  */
  1184. X   OR,               aohand,  2,    4,             /* 0x08  */
  1185. X   OR,               aohand,  2,    4,             /* 0x09  */
  1186. X   OR,               aohand,  2,    4,             /* 0x0a  */
  1187. X   OR,               aohand,  2,    4,             /* 0x0b  */
  1188. X   OR,               aohand,  2,    2,             /* 0x0c  */
  1189. X   OR,               aohand,  3,    3,             /* 0x0d  */
  1190. X   "\tpush\tcs",     sbhand,  1,    1,             /* 0x0e  */
  1191. X   NULL,             dfhand,  0,    0,             /* 0x0f  */
  1192. X   ADC,              aohand,  2,    4,             /* 0x10  */
  1193. X   ADC,              aohand,  2,    4,             /* 0x11  */
  1194. X   ADC,              aohand,  2,    4,             /* 0x12  */
  1195. X   ADC,              aohand,  2,    4,             /* 0x13  */
  1196. X   ADC,              aohand,  2,    2,             /* 0x14  */
  1197. X   ADC,              aohand,  3,    3,             /* 0x15  */
  1198. X   "\tpush\tss",     sbhand,  1,    1,             /* 0x16  */
  1199. X   "\tpop\tss",      sbhand,  1,    1,             /* 0x17  */
  1200. X   SBB,              aohand,  2,    4,             /* 0x18  */
  1201. X   SBB,              aohand,  2,    4,             /* 0x19  */
  1202. X   SBB,              aohand,  2,    4,             /* 0x1a  */
  1203. X   SBB,              aohand,  2,    4,             /* 0x1b  */
  1204. X   SBB,              aohand,  2,    2,             /* 0x1c  */
  1205. X   SBB,              aohand,  3,    3,             /* 0x1d  */
  1206. X   "\tpush\tds",     sbhand,  1,    1,             /* 0x1e  */
  1207. X   "\tpop\tds",      sbhand,  1,    1,             /* 0x1f  */
  1208. X   AND,              aohand,  2,    4,             /* 0x20  */
  1209. X   AND,              aohand,  2,    4,             /* 0x21  */
  1210. X   AND,              aohand,  2,    4,             /* 0x22  */
  1211. X   AND,              aohand,  2,    4,             /* 0x23  */
  1212. X   AND,              aohand,  2,    2,             /* 0x24  */
  1213. X   AND,              aohand,  3,    3,             /* 0x25  */
  1214. X   "\tseg\tes",      sbhand,  1,    1,             /* 0x26  */
  1215. X   "\tdaa",          sbhand,  1,    1,             /* 0x27  */
  1216. X   SUB,              aohand,  2,    4,             /* 0x28  */
  1217. X   SUB,              aohand,  2,    4,             /* 0x29  */
  1218. X   SUB,              aohand,  2,    4,             /* 0x2a  */
  1219. X   SUB,              aohand,  2,    4,             /* 0x2b  */
  1220. X   SUB,              aohand,  2,    2,             /* 0x2c  */
  1221. X   SUB,              aohand,  3,    3,             /* 0x2d  */
  1222. X   "\tseg\tcs",      sbhand,  1,    1,             /* 0x2e  */
  1223. X   "\tdas",          sbhand,  1,    1,             /* 0x2f  */
  1224. X   XOR,              aohand,  2,    4,             /* 0x30  */
  1225. X   XOR,              aohand,  2,    4,             /* 0x31  */
  1226. X   XOR,              aohand,  2,    4,             /* 0x32  */
  1227. X   XOR,              aohand,  2,    4,             /* 0x33  */
  1228. X   XOR,              aohand,  2,    2,             /* 0x34  */
  1229. X   XOR,              aohand,  3,    3,             /* 0x35  */
  1230. X   "\tseg\tss",      sbhand,  1,    1,             /* 0x36  */
  1231. X   "\taaa",          sbhand,  1,    1,             /* 0x37  */
  1232. X   CMP,              aohand,  2,    4,             /* 0x38  */
  1233. X   CMP,              aohand,  2,    4,             /* 0x39  */
  1234. X   CMP,              aohand,  2,    4,             /* 0x3a  */
  1235. X   CMP,              aohand,  2,    4,             /* 0x3b  */
  1236. X   CMP,              aohand,  2,    2,             /* 0x3c  */
  1237. X   CMP,              aohand,  3,    3,             /* 0x3d  */
  1238. X   "\tseg\tds",      sbhand,  1,    1,             /* 0x3e  */
  1239. X   "\taas",          sbhand,  1,    1,             /* 0x3f  */
  1240. X   "\tinc\tax",      sbhand,  1,    1,             /* 0x40  */
  1241. X   "\tinc\tcx",      sbhand,  1,    1,             /* 0x41  */
  1242. X   "\tinc\tdx",      sbhand,  1,    1,             /* 0x42  */
  1243. X   "\tinc\tbx",      sbhand,  1,    1,             /* 0x43  */
  1244. X   "\tinc\tsp",      sbhand,  1,    1,             /* 0x44  */
  1245. X   "\tinc\tbp",      sbhand,  1,    1,             /* 0x45  */
  1246. X   "\tinc\tsi",      sbhand,  1,    1,             /* 0x46  */
  1247. X   "\tinc\tdi",      sbhand,  1,    1,             /* 0x47  */
  1248. X   "\tdec\tax",      sbhand,  1,    1,             /* 0x48  */
  1249. X   "\tdec\tcx",      sbhand,  1,    1,             /* 0x49  */
  1250. X   "\tdec\tdx",      sbhand,  1,    1,             /* 0x4a  */
  1251. X   "\tdec\tbx",      sbhand,  1,    1,             /* 0x4b  */
  1252. X   "\tdec\tsp",      sbhand,  1,    1,             /* 0x4c  */
  1253. X   "\tdec\tbp",      sbhand,  1,    1,             /* 0x4d  */
  1254. X   "\tdec\tsi",      sbhand,  1,    1,             /* 0x4e  */
  1255. X   "\tdec\tdi",      sbhand,  1,    1,             /* 0x4f  */
  1256. X   "\tpush\tax",     sbhand,  1,    1,             /* 0x50  */
  1257. X   "\tpush\tcx",     sbhand,  1,    1,             /* 0x51  */
  1258. X   "\tpush\tdx",     sbhand,  1,    1,             /* 0x52  */
  1259. X   "\tpush\tbx",     sbhand,  1,    1,             /* 0x53  */
  1260. X   "\tpush\tsp",     sbhand,  1,    1,             /* 0x54  */
  1261. X   "\tpush\tbp",     sbhand,  1,    1,             /* 0x55  */
  1262. X   "\tpush\tsi",     sbhand,  1,    1,             /* 0x56  */
  1263. X   "\tpush\tdi",     sbhand,  1,    1,             /* 0x57  */
  1264. X   "\tpop\tax",      sbhand,  1,    1,             /* 0x58  */
  1265. X   "\tpop\tcx",      sbhand,  1,    1,             /* 0x59  */
  1266. X   "\tpop\tdx",      sbhand,  1,    1,             /* 0x5a  */
  1267. X   "\tpop\tbx",      sbhand,  1,    1,             /* 0x5b  */
  1268. X   "\tpop\tsp",      sbhand,  1,    1,             /* 0x5c  */
  1269. X   "\tpop\tbp",      sbhand,  1,    1,             /* 0x5d  */
  1270. X   "\tpop\tsi",      sbhand,  1,    1,             /* 0x5e  */
  1271. X   "\tpop\tdi",      sbhand,  1,    1,             /* 0x5f  */
  1272. X   NULL,             dfhand,  0,    0,             /* 0x60  */
  1273. X   NULL,             dfhand,  0,    0,             /* 0x61  */
  1274. X   NULL,             dfhand,  0,    0,             /* 0x62  */
  1275. X   NULL,             dfhand,  0,    0,             /* 0x63  */
  1276. X   NULL,             dfhand,  0,    0,             /* 0x64  */
  1277. X   NULL,             dfhand,  0,    0,             /* 0x65  */
  1278. X   NULL,             dfhand,  0,    0,             /* 0x66  */
  1279. X   NULL,             dfhand,  0,    0,             /* 0x67  */
  1280. X   NULL,             dfhand,  0,    0,             /* 0x68  */
  1281. X   NULL,             dfhand,  0,    0,             /* 0x69  */
  1282. X   NULL,             dfhand,  0,    0,             /* 0x6a  */
  1283. X   NULL,             dfhand,  0,    0,             /* 0x6b  */
  1284. X   NULL,             dfhand,  0,    0,             /* 0x6c  */
  1285. X   NULL,             dfhand,  0,    0,             /* 0x6d  */
  1286. X   NULL,             dfhand,  0,    0,             /* 0x6e  */
  1287. X   NULL,             dfhand,  0,    0,             /* 0x6f  */
  1288. X   "\tjo",           sjhand,  2,    2,             /* 0x70  */
  1289. X   "\tjno",          sjhand,  2,    2,             /* 0x71  */
  1290. X   "\tjc",           sjhand,  2,    2,             /* 0x72  */
  1291. X   "\tjnc",          sjhand,  2,    2,             /* 0x73  */
  1292. X   "\tjz",           sjhand,  2,    2,             /* 0x74  */
  1293. X   "\tjnz",          sjhand,  2,    2,             /* 0x75  */
  1294. X   "\tjna",          sjhand,  2,    2,             /* 0x76  */
  1295. X   "\tja",           sjhand,  2,    2,             /* 0x77  */
  1296. X   "\tjs",           sjhand,  2,    2,             /* 0x78  */
  1297. X   "\tjns",          sjhand,  2,    2,             /* 0x79  */
  1298. X   "\tjp",           sjhand,  2,    2,             /* 0x7a  */
  1299. X   "\tjnp",          sjhand,  2,    2,             /* 0x7b  */
  1300. X   "\tjl",           sjhand,  2,    2,             /* 0x7c  */
  1301. X   "\tjnl",          sjhand,  2,    2,             /* 0x7d  */
  1302. X   "\tjng",          sjhand,  2,    2,             /* 0x7e  */
  1303. X   "\tjg",           sjhand,  2,    2,             /* 0x7f  */
  1304. X   AMBIG,            imhand,  3,    5,             /* 0x80  */
  1305. X   AMBIG,            imhand,  4,    6,             /* 0x81  */
  1306. X   AMBIG,            imhand,  3,    5,             /* 0x82  */
  1307. X   AMBIG,            imhand,  3,    5,             /* 0x83  */
  1308. X   TEST,             mvhand,  2,    4,             /* 0x84  */
  1309. X   TEST,             mvhand,  2,    4,             /* 0x85  */
  1310. X   "\txchg",         mvhand,  2,    4,             /* 0x86  */
  1311. X   "\txchg",         mvhand,  2,    4,             /* 0x87  */
  1312. X   MOV,              mvhand,  2,    4,             /* 0x88  */
  1313. X   MOV,              mvhand,  2,    4,             /* 0x89  */
  1314. X   MOV,              mvhand,  2,    4,             /* 0x8a  */
  1315. X   MOV,              mvhand,  2,    4,             /* 0x8b  */
  1316. X   MOV,              mshand,  2,    4,             /* 0x8c  */
  1317. X   "\tlea",          mvhand,  2,    4,             /* 0x8d  */
  1318. X   MOV,              mshand,  2,    4,             /* 0x8e  */
  1319. X   "\tpop",          pohand,  2,    4,             /* 0x8f  */
  1320. X   "\tnop",          sbhand,  1,    1,             /* 0x90  */
  1321. X   "\txchg\tax,cx",  sbhand,  1,    1,             /* 0x91  */
  1322. X   "\txchg\tax,dx",  sbhand,  1,    1,             /* 0x92  */
  1323. X   "\txchg\tax,bx",  sbhand,  1,    1,             /* 0x93  */
  1324. X   "\txchg\tax,sp",  sbhand,  1,    1,             /* 0x94  */
  1325. X   "\txchg\tax,bp",  sbhand,  1,    1,             /* 0x95  */
  1326. X   "\txchg\tax,si",  sbhand,  1,    1,             /* 0x96  */
  1327. X   "\txchg\tax,di",  sbhand,  1,    1,             /* 0x97  */
  1328. X   "\tcbw",          sbhand,  1,    1,             /* 0x98  */
  1329. X   "\tcwd",          sbhand,  1,    1,             /* 0x99  */
  1330. X   "\tcalli",        cihand,  5,    5,             /* 0x9a  */
  1331. X   "\twait",         sbhand,  1,    1,             /* 0x9b  */
  1332. X   "\tpushf",        sbhand,  1,    1,             /* 0x9c  */
  1333. X   "\tpopf",         sbhand,  1,    1,             /* 0x9d  */
  1334. X   "\tsahf",         sbhand,  1,    1,             /* 0x9e  */
  1335. X   "\tlahf",         sbhand,  1,    1,             /* 0x9f  */
  1336. X   MOV,              mqhand,  3,    3,             /* 0xa0  */
  1337. X   MOV,              mqhand,  3,    3,             /* 0xa1  */
  1338. X   MOV,              mqhand,  3,    3,             /* 0xa2  */
  1339. X   MOV,              mqhand,  3,    3,             /* 0xa3  */
  1340. X   "\tmovb",         sbhand,  1,    1,             /* 0xa4  */
  1341. X   "\tmovw",         sbhand,  1,    1,             /* 0xa5  */
  1342. X   "\tcmpb",         sbhand,  1,    1,             /* 0xa6  */
  1343. X   "\tcmpw",         sbhand,  1,    1,             /* 0xa7  */
  1344. X   TEST,             tqhand,  2,    2,             /* 0xa8  */
  1345. X   TEST,             tqhand,  3,    3,             /* 0xa9  */
  1346. X   "\tstob",         sbhand,  1,    1,             /* 0xaa  */
  1347. X   "\tstow",         sbhand,  1,    1,             /* 0xab  */
  1348. X   "\tlodb",         sbhand,  1,    1,             /* 0xac  */
  1349. X   "\tlodw",         sbhand,  1,    1,             /* 0xad  */
  1350. X   "\tscab",         sbhand,  1,    1,             /* 0xae  */
  1351. X   "\tscaw",         sbhand,  1,    1,             /* 0xaf  */
  1352. X   "\tmov\tal,",     mihand,  2,    2,             /* 0xb0  */
  1353. X   "\tmov\tcl,",     mihand,  2,    2,             /* 0xb1  */
  1354. X   "\tmov\tdl,",     mihand,  2,    2,             /* 0xb2  */
  1355. X   "\tmov\tbl,",     mihand,  2,    2,             /* 0xb3  */
  1356. X   "\tmov\tah,",     mihand,  2,    2,             /* 0xb4  */
  1357. X   "\tmov\tch,",     mihand,  2,    2,             /* 0xb5  */
  1358. X   "\tmov\tdh,",     mihand,  2,    2,             /* 0xb6  */
  1359. X   "\tmov\tbh,",     mihand,  2,    2,             /* 0xb7  */
  1360. X   "\tmov\tax,",     mihand,  3,    3,             /* 0xb8  */
  1361. X   "\tmov\tcx,",     mihand,  3,    3,             /* 0xb9  */
  1362. X   "\tmov\tdx,",     mihand,  3,    3,             /* 0xba  */
  1363. X   "\tmov\tbx,",     mihand,  3,    3,             /* 0xbb  */
  1364. X   "\tmov\tsp,",     mihand,  3,    3,             /* 0xbc  */
  1365. X   "\tmov\tbp,",     mihand,  3,    3,             /* 0xbd  */
  1366. X   "\tmov\tsi,",     mihand,  3,    3,             /* 0xbe  */
  1367. X   "\tmov\tdi,",     mihand,  3,    3,             /* 0xbf  */
  1368. X   NULL,             dfhand,  0,    0,             /* 0xc0  */
  1369. X   NULL,             dfhand,  0,    0,             /* 0xc1  */
  1370. X   "\tret",          rehand,  3,    3,             /* 0xc2  */
  1371. X   "\tret",          sbhand,  1,    1,             /* 0xc3  */
  1372. X   "\tles",          mvhand,  2,    4,             /* 0xc4  */
  1373. X   "\tlds",          mvhand,  2,    4,             /* 0xc5  */
  1374. X   MOV,              mmhand,  3,    5,             /* 0xc6  */
  1375. X   MOV,              mmhand,  4,    6,             /* 0xc7  */
  1376. X   NULL,             dfhand,  0,    0,             /* 0xc8  */
  1377. X   NULL,             dfhand,  0,    0,             /* 0xc9  */
  1378. X   "\treti",         rehand,  3,    3,             /* 0xca  */
  1379. X   "\treti",         sbhand,  1,    1,             /* 0xcb  */
  1380. X   "\tint",          sbhand,  1,    1,             /* 0xcc  */
  1381. X   "\tint",          inhand,  2,    2,             /* 0xcd  */
  1382. X   "\tinto",         sbhand,  1,    1,             /* 0xce  */
  1383. X   "\tiret",         sbhand,  1,    1,             /* 0xcf  */
  1384. X   AMBIG,            srhand,  2,    4,             /* 0xd0  */
  1385. X   AMBIG,            srhand,  2,    4,             /* 0xd1  */
  1386. X   AMBIG,            srhand,  2,    4,             /* 0xd2  */
  1387. X   AMBIG,            srhand,  2,    4,             /* 0xd3  */
  1388. X   "\taam",          aahand,  2,    2,             /* 0xd4  */
  1389. X   "\taad",          aahand,  2,    2,             /* 0xd5  */
  1390. X   NULL,             dfhand,  0,    0,             /* 0xd6  */
  1391. X   "\txlat",         sbhand,  1,    1,             /* 0xd7  */
  1392. X   ESC,              eshand,  2,    2,             /* 0xd8  */
  1393. X   ESC,              eshand,  2,    2,             /* 0xd9  */
  1394. X   ESC,              eshand,  2,    2,             /* 0xda  */
  1395. X   ESC,              eshand,  2,    2,             /* 0xdb  */
  1396. X   ESC,              eshand,  2,    2,             /* 0xdc  */
  1397. X   ESC,              eshand,  2,    2,             /* 0xdd  */
  1398. X   ESC,              eshand,  2,    2,             /* 0xde  */
  1399. X   ESC,              eshand,  2,    2,             /* 0xdf  */
  1400. X   "\tloopne",       sjhand,  2,    2,             /* 0xe0  */
  1401. X   "\tloope",        sjhand,  2,    2,             /* 0xe1  */
  1402. X   "\tloop",         sjhand,  2,    2,             /* 0xe2  */
  1403. X   "\tjcxz",         sjhand,  2,    2,             /* 0xe3  */
  1404. X   "\tin",           iohand,  2,    2,             /* 0xe4  */
  1405. X   "\tinw",          iohand,  2,    2,             /* 0xe5  */
  1406. X   "\tout",          iohand,  2,    2,             /* 0xe6  */
  1407. X   "\toutw",         iohand,  2,    2,             /* 0xe7  */
  1408. X   "\tcall",         ljhand,  3,    3,             /* 0xe8  */
  1409. X   "\tjmp",          ljhand,  3,    3,             /* 0xe9  */
  1410. X   "\tjmpi",         cihand,  5,    5,             /* 0xea  */
  1411. X   "\tj",            sjhand,  2,    2,             /* 0xeb  */
  1412. X   "\tin",           sbhand,  1,    1,             /* 0xec  */
  1413. X   "\tinw",          sbhand,  1,    1,             /* 0xed  */
  1414. X   "\tout",          sbhand,  1,    1,             /* 0xee  */
  1415. X   "\toutw",         sbhand,  1,    1,             /* 0xef  */
  1416. X   "\tlock",         sbhand,  1,    1,             /* 0xf0  */
  1417. X   NULL,             dfhand,  0,    0,             /* 0xf1  */
  1418. X   "\trepnz",        sbhand,  1,    1,             /* 0xf2  */
  1419. X   "\trepz",         sbhand,  1,    1,             /* 0xf3  */
  1420. X   "\thlt",          sbhand,  1,    1,             /* 0xf4  */
  1421. X   "\tcmc",          sbhand,  1,    1,             /* 0xf5  */
  1422. X   AMBIG,            mahand,  2,    5,             /* 0xf6  */
  1423. X   AMBIG,            mahand,  2,    6,             /* 0xf7  */
  1424. X   "\tclc",          sbhand,  1,    1,             /* 0xf8  */
  1425. X   "\tstc",          sbhand,  1,    1,             /* 0xf9  */
  1426. X   "\tcli",          sbhand,  1,    1,             /* 0xfa  */
  1427. X   "\tsti",          sbhand,  1,    1,             /* 0xfb  */
  1428. X   "\tcld",          sbhand,  1,    1,             /* 0xfc  */
  1429. X   "\tstd",          sbhand,  1,    1,             /* 0xfd  */
  1430. X   AMBIG,            mjhand,  2,    4,             /* 0xfe  */
  1431. X   AMBIG,            mjhand,  2,    4              /* 0xff  */
  1432. X   };
  1433. X
  1434. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1435. X  *                                                         *
  1436. X  * This simple routine  returns the name field of a symbol *
  1437. X  * table entry as a printable string.                      *
  1438. X  *                                                         *
  1439. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1440. X
  1441. char *
  1442. getnam(k)
  1443. X
  1444. X   register int k;
  1445. X
  1446. X{/* * * * * * * * * *  START OF getnam()  * * * * * * * * * */
  1447. X
  1448. X   register int j;
  1449. X   static char a[9];
  1450. X
  1451. X   for (j = 0; j < 8; ++j)
  1452. X      if ( ! symtab[k].n_name[j] )
  1453. X         break;
  1454. X      else
  1455. X         a[j] = symtab[k].n_name[j];
  1456. X
  1457. X   a[j] = '\0';
  1458. X
  1459. X   return (a);
  1460. X
  1461. X}/* * * * * * * * * * * END OF getnam() * * * * * * * * * * */
  1462. X
  1463. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1464. X  *                                                         *
  1465. X  * This function is  responsible  for mucking  through the *
  1466. X  * relocation  table in  search of  externally  referenced *
  1467. X  * symbols to be output as  operands.  It accepts two long *
  1468. X  * arguments: the code-segment location at which an extern *
  1469. X  * reference  is  expected,  and the offset value which is *
  1470. X  * embedded  in the  object  code and used at link time to *
  1471. X  * bias the external value.  In the most typical case, the *
  1472. X  * function will be called by lookup(), which always makes *
  1473. X  * a check for external names before  searching the symbol *
  1474. X  * table proper.  However,  it may also be called directly *
  1475. X  * by any function  (such as the  move-immediate  handler) *
  1476. X  * which wants to make an independent check for externals. *
  1477. X  * The caller is expected to supply, as the third argument *
  1478. X  * to the function,  a pointer to a character buffer large *
  1479. X  * enough to hold any possible  output  string.  Lookext() *
  1480. X  * will fill this  buffer and return a logical  TRUE if it *
  1481. X  * finds an extern reference;  otherwise, it will return a *
  1482. X  * logical FALSE, leaving the buffer undisturbed.          *
  1483. X  *                                                         *
  1484. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1485. X
  1486. int
  1487. lookext(off,loc,buf)
  1488. X
  1489. X   long off, loc;
  1490. X   char *buf;
  1491. X
  1492. X{/* * * * * * * * * * START OF  lookext() * * * * * * * * * */
  1493. X
  1494. X   register int k;
  1495. X   char c[16];
  1496. X
  1497. X   if ((loc != -1L) && (relptr >= 0))
  1498. X      for (k = 0; k <= relptr; ++k)
  1499. X         if ((relo[k].r_vaddr == loc)
  1500. X          && (relo[k].r_symndx < S_BSS))
  1501. X            {
  1502. X            strcpy(buf,getnam(relo[k].r_symndx));
  1503. X            if (off)
  1504. X               {
  1505. X               if (off < 0)
  1506. X                  sprintf(c,"%ld",off);
  1507. X               else
  1508. X                  sprintf(c,"+%ld",off);
  1509. X               strcat(buf,c);
  1510. X               }
  1511. X            return (1);
  1512. X            }
  1513. X
  1514. X   return (0);
  1515. X
  1516. X}/* * * * * * * * * *  END OF  lookext()  * * * * * * * * * */
  1517. X
  1518. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1519. X  *                                                         *
  1520. X  * This  function  finds an entry in the  symbol  table by *
  1521. X  * value.  Its input is a (long) machine address,  and its *
  1522. X  * output is a pointer to a string  containing  the corre- *
  1523. X  * sponding symbolic name. The function first searches the *
  1524. X  * relocation table for a possible external reference;  if *
  1525. X  * none is found,  a linear  search of the symbol table is *
  1526. X  * undertaken. If no matching symbol has been found at the *
  1527. X  * end of these searches,  the function  returns a pointer *
  1528. X  * to a string  containing the ASCII equivalent of the ad- *
  1529. X  * dress which was to be located,  so that,  regardless of *
  1530. X  * the success of the search,  the function's return value *
  1531. X  * is suitable for use as a memory-reference operand.  The *
  1532. X  * caller specifies the type of symbol to be found  (text, *
  1533. X  * data, bss, undefined,  absolute, or common) by means of *
  1534. X  * the function's  second  parameter.  The third parameter *
  1535. X  * specifies  the  format to be used in the event of a nu- *
  1536. X  * meric output:  zero for absolute format,  one for short *
  1537. X  * relative  format,  two for long  relative  format.  The *
  1538. X  * fourth  parameter is the address  which would appear in *
  1539. X  * the relocation table for the reference in question,  or *
  1540. X  * -1 if the relocation  table is not to be searched.  The *
  1541. X  * function attempts to apply a certain amount of intelli- *
  1542. X  * gence in its  selection  of symbols,  so it is possible *
  1543. X  * that,  in the absence of a type match,  a symbol of the *
  1544. X  * correct value but different type will be returned.      *
  1545. X  *                                                         *
  1546. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1547. X
  1548. char *
  1549. lookup(addr,type,kind,ext)
  1550. X
  1551. X   long addr;              /* Machine address to be located */
  1552. X
  1553. X   int type,               /* Type of symbol to be matched  */
  1554. X       kind;               /* Addressing output mode to use */
  1555. X
  1556. X   long ext;               /* Value for extern ref, if any  */
  1557. X
  1558. X{/* * * * * * * * * *  START OF lookup()  * * * * * * * * * */
  1559. X
  1560. X   register int j, k;
  1561. X   static char b[64];
  1562. X
  1563. X   struct
  1564. X      {
  1565. X      int   i;
  1566. X      int   t;
  1567. X      }
  1568. X   best;
  1569. X
  1570. X   if (lookext(addr,ext,b))
  1571. X      return (b);
  1572. X
  1573. X   if (segflg)
  1574. X      if (segflg & 1)
  1575. X         type = N_TEXT;
  1576. X      else
  1577. X         type = N_DATA;
  1578. X
  1579. X   for (k = 0, best.i = -1; k <= symptr; ++k)
  1580. X      if (symtab[k].n_value == addr)
  1581. X         if ((j = symtab[k].n_sclass & N_SECT) == type)
  1582. X            {
  1583. X            best.t = j;
  1584. X            best.i = k;
  1585. X            break;
  1586. X            }
  1587. X         else if (segflg || (HDR.a_flags & A_SEP))
  1588. X            continue;
  1589. X         else if (best.i < 0)
  1590. X            best.t = j, best.i = k;
  1591. X         else if (symrank[type][j] > symrank[type][best.t])
  1592. X            best.t = j, best.i = k;
  1593. X
  1594. X   if (best.i >= 0)
  1595. X      return (getnam(best.i));
  1596. X
  1597. X   if (kind == LOOK_ABS)
  1598. X      sprintf(b,"0x%05.5x",addr);
  1599. X   else
  1600. X      {
  1601. X      long x = addr - (PC - kind);
  1602. X      if (x < 0)
  1603. X         sprintf(b,".%ld",x);
  1604. X      else
  1605. X         sprintf(b,".+%ld",x);
  1606. X      }
  1607. X
  1608. X   return (b);
  1609. X
  1610. X}/* * * * * * * * * * * END OF lookup() * * * * * * * * * * */
  1611. X
  1612. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1613. X  *                                                         *
  1614. X  * This function  translates an 8088  addressing mode byte *
  1615. X  * to an equivalent assembler string,  returning a pointer *
  1616. X  * thereto.  If necessary,  it performs  successive inputs *
  1617. X  * of bytes from the object file in order to obtain offset *
  1618. X  * data,  adjusting PC  accordingly.  (The addressing mode *
  1619. X  * byte  appears in several  8088  opcodes;  it is used to *
  1620. X  * specify source and destination operand locations.)  The *
  1621. X  * third  argument to the function is zero if the standard *
  1622. X  * registers are to be used,  or eight if the segment reg- *
  1623. X  * isters are to be used; these constants are defined sym- *
  1624. X  * bolically in dis.h.  NOTE:  The mtrans()  function must *
  1625. X  * NEVER be called except  immediately  after fetching the *
  1626. X  * mode byte.  If any additional  object bytes are fetched *
  1627. X  * after  the fetch of the mode  byte,  mtrans()  will not *
  1628. X  * produce correct output!                                 *
  1629. X  *                                                         *
  1630. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1631. X
  1632. char *
  1633. mtrans(c,m,type)
  1634. X
  1635. X   register int c;            /* Primary instruction byte   */
  1636. X   register int m;            /* Addressing mode byte       */
  1637. X
  1638. X   int type;                  /* Type code: standard or seg */
  1639. X
  1640. X{/* * * * * * * * * *  START OF mtrans()  * * * * * * * * * */
  1641. X
  1642. X   unsigned long pc;
  1643. X   int offset, oflag, dir, w, mod, reg, rm;
  1644. X   static char a[100];
  1645. X   static char b[30];
  1646. X
  1647. X   offset = 0;
  1648. X   dir = c & 2;
  1649. X   w = c & 1;
  1650. X   mod = (m & 0xc0) >> 6;
  1651. X   reg = (m & 0x38) >> 3;
  1652. X   rm = m & 7;
  1653. X   pc = PC + 1;
  1654. X
  1655. X   if (type)
  1656. X      w = 1;
  1657. X
  1658. X   if ((oflag = mod) > 2)
  1659. X      oflag = 0;
  1660. X
  1661. X   if (oflag)
  1662. X      {
  1663. X      int j, k;
  1664. X      if (oflag == 2)
  1665. X         {
  1666. X         FETCH(j);
  1667. X         FETCH(k);
  1668. X         offset = (k << 8) | j;
  1669. X         }
  1670. X      else
  1671. X         {
  1672. X         FETCH(j);
  1673. X         if (j & 0x80)
  1674. X            k = 0xff00;
  1675. X         else
  1676. X            k = 0;
  1677. X         offset = k | j;
  1678. X         }
  1679. X      }
  1680. X
  1681. X   if (dir)
  1682. X      {
  1683. X      strcpy(a,REGS[type + ((w << 3) | reg)]);
  1684. X      strcat(a,",");
  1685. X      switch (mod)
  1686. X         {
  1687. X         case 0 :
  1688. X            if (rm == 6)
  1689. X               {
  1690. X               int j, k;
  1691. X               FETCH(j);
  1692. X               FETCH(k);
  1693. X               offset = (k << 8) | j;
  1694. X               strcat(a,
  1695. X                lookup((long)(offset),N_DATA,LOOK_ABS,pc));
  1696. X               }
  1697. X            else
  1698. X               {
  1699. X               sprintf(b,"(%s)",REGS0[rm]);
  1700. X               strcat(a,b);
  1701. X               }
  1702. X            break;
  1703. X         case 1 :
  1704. X         case 2 :
  1705. X            if (mod == 1)
  1706. X               strcat(a,"*");
  1707. X            else
  1708. X               strcat(a,"#");
  1709. X            sprintf(b,"%d(",offset);
  1710. X            strcat(a,b);
  1711. X            strcat(a,REGS1[rm]);
  1712. X            strcat(a,")");
  1713. X            break;
  1714. X         case 3 :
  1715. X            strcat(a,REGS[(w << 3) | rm]);
  1716. X            break;
  1717. X         }
  1718. X      }
  1719. X   else
  1720. X      {
  1721. X      switch (mod)
  1722. X         {
  1723. X         case 0 :
  1724. X            if (rm == 6)
  1725. X               {
  1726. X               int j, k;
  1727. X               FETCH(j);
  1728. X               FETCH(k);
  1729. X               offset = (k << 8) | j;
  1730. X               strcpy(a,
  1731. X                lookup((long)(offset),N_DATA,LOOK_ABS,pc));
  1732. X               }
  1733. X            else
  1734. X               {
  1735. X               sprintf(b,"(%s)",REGS0[rm]);
  1736. X               strcpy(a,b);
  1737. X               }
  1738. X            break;
  1739. X         case 1 :
  1740. X         case 2 :
  1741. X            if (mod == 1)
  1742. X               strcpy(a,"*");
  1743. X            else
  1744. X               strcpy(a,"#");
  1745. X            sprintf(b,"%d(",offset);
  1746. X            strcat(a,b);
  1747. X            strcat(a,REGS1[rm]);
  1748. X            strcat(a,")");
  1749. X            break;
  1750. X         case 3 :
  1751. X            strcpy(a,REGS[(w << 3) | rm]);
  1752. X            break;
  1753. X         }
  1754. X      strcat(a,",");
  1755. X      strcat(a,REGS[type + ((w << 3) | reg)]);
  1756. X      }
  1757. X
  1758. X   return (a);
  1759. X
  1760. X}/* * * * * * * * * * * END OF mtrans() * * * * * * * * * * */
  1761. X
  1762. X /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  1763. X  *                                                         *
  1764. X  * This simple routine  truncates a string returned by the *
  1765. X  * mtrans() function, removing its source operand. This is *
  1766. X  * useful in handlers which ignore the "reg"  field of the *
  1767. X  * mode byte.                                              *
  1768. X  *                                                         *
  1769. X  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  1770. X
  1771. void
  1772. mtrunc(a)
  1773. X
  1774. X   register char *a;          /* Ptr. to string to truncate */
  1775. X
  1776. X{/* * * * * * * * * *  START OF mtrunc()  * * * * * * * * * */
  1777. X
  1778. X   register int k;
  1779. X
  1780. X   for (k = strlen(a) - 1; k >= 0; --k)
  1781. X      if (a[k] == ',')
  1782. X         {
  1783. X         a[k] = '\0';
  1784. X         break;
  1785. X         }
  1786. X
  1787. X}/* * * * * * * * * * * END OF mtrunc() * * * * * * * * * * */
  1788. X
  1789. X
  1790. END_OF_FILE
  1791. if test 30238 -ne `wc -c <'distabs.c'`; then
  1792.     echo shar: \"'distabs.c'\" unpacked with wrong size!
  1793. fi
  1794. # end of 'distabs.c'
  1795. fi
  1796. echo shar: End of archive 2 \(of 2\).
  1797. cp /dev/null ark2isdone
  1798. MISSING=""
  1799. for I in 1 2 ; do
  1800.     if test ! -f ark${I}isdone ; then
  1801.     MISSING="${MISSING} ${I}"
  1802.     fi
  1803. done
  1804. if test "${MISSING}" = "" ; then
  1805.     echo You have unpacked both archives.
  1806.     rm -f ark[1-9]isdone
  1807. else
  1808.     echo You still need to unpack the following archives:
  1809.     echo "        " ${MISSING}
  1810. fi
  1811. ##  End of shell archive.
  1812. exit 0
  1813.